﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ChoDiaOc_HK_WPF.Controls;
using ChoDiaOc_HK_WPF.Models;

namespace ChoDiaOc_HK_WPF.Views.LapBaoBieu {
    /// <summary>
    /// Interaction logic for ThongKeDoanhThu.xaml
    /// </summary>
    public partial class ThongKeDoanhThu : UserControl {
        private List<TKDoanhThu> ListDoanhThu;
        List<PHIEUDANGKY> query;
        public ThongKeDoanhThu() {
            InitializeComponent();
            List<string> Thang = new List<string>();
            Thang.Add("1");
            Thang.Add("2");
            Thang.Add("3");
            Thang.Add("4");
            Thang.Add("5");
            Thang.Add("6");
            Thang.Add("7");
            Thang.Add("8");
            Thang.Add("9");
            Thang.Add("10");
            Thang.Add("11");
            Thang.Add("12");
            cbxThang.ItemsSource = Thang;
        }

        private void cbxThang_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            query = DatabaseWrapper.GetInstance().GetAllPhieuDangKy();
            float tongDT = 0;
            int nam;
            if (int.TryParse(tbxNam.Text, out nam))
                ListDoanhThu = TKDoanhThu.getListDoanhThu(query, int.Parse(cbxThang.SelectedItem.ToString()), nam, ref tongDT);
            TongDoanhThutextBlock.Text = tongDT.ToString();
            TKDTdataGrid.ItemsSource = ListDoanhThu;
        }
    }
}
